#include <stdio.h>
#include <string.h>

/*
 *	对应/develop/c/结构体强制类型转换.c		2015/1/16 16:04		jin
 */


struct A{  
    int num;  
};  
  
struct B{  
    int num;  
    char type;  
    int age;  
};  
  
int main()  
{  
    struct A a;  
    a.num=1;  
  
    char* tmp1=(char *)(&(a.num)); 
	
	printf("%d\n", *tmp1);	// 1

    tmp1=tmp1+4;  

	printf("%d\n", *tmp1);	// -128

    *tmp1='a';  

    int *tmp2=(int *)(&(a.num));  

    tmp2=tmp2+2;  

    *tmp2=100;  
  
    struct B *b=(struct B *)(&a);  
  
    printf(" b->num=%d  b->type=%c  b->age=%d \n",b->num,b->type,b->age);	
	// output:
	// b->num=1  b->type=P  b->age=100
}  



